//
//  AppError.m
//  suishouxiu
//
//  Created by dinghongyan on 15/6/11.
//  Copyright (c) 2015年 zhongyan. All rights reserved.
//

#import "AppError.h"
#import "NSArray+SafeAccess.h"
#import "NSDictionary+SafeAccess.h"

@interface AppError()
@property (nonatomic) NSDictionary *errorDictionary;
@end
@implementation AppError

+(NSString *)messageForErrorCode:(NSInteger)error_code{
    NSString * errorMsg = [[AppError errorDictionary] stringForKey:[self enumName:error_code]];
    errorMsg = errorMsg ? errorMsg : @"未知错误";
    return errorMsg;
}

+(NSDictionary *)errorDictionary{
    return @{[self enumName:ERROR_JSON_FORMAT]:@"格式错误",
             [self enumName:ERROR_ACCESS_TOKEN]:@"验证失败",
             [self enumName:ERROR_AUTHOR]:@"用户不正确",
             [self enumName:ERROR_USER_NOT_MATCH_CREATOR]:@"当前用户不正确",
           
             [self enumName:ERROR_FUNC_NOT_FOUND]:@"类型不存在",
             [self enumName:ERROR_PROJECT_NOT_FOUND]:@"项目不存在",
             [self enumName:ERROR_PAGE_UPDATE]:@"更新页出错",
             [self enumName:ERROR_PARA_VERIFIY]:@"参数验证失败",
             [self enumName:ERROR_STORE_ADD_FAILED]:@"新增失败",
             [self enumName:ERROR_STORE_MODIFY_FAILED]:@"修改失败",
             [self enumName:ERROR_OLD_PASSWORD_AUTHENTICATION_FAILED]:@"旧密码验证失败!",
             [self enumName:USERNAME_NOT_MATCH_PASSWORD]:@"用户名密码不匹配!",
             [self enumName:APPEAL]:@"出错了",
             };
}

+(NSString *)enumName:(NSInteger)enumItem{
    return [NSString stringWithFormat:@"%ld",(long)enumItem];
}
@end
